import Vue from 'vue';
import Vuex from 'vuex';
import App from './App';
import router from './router';
import store from './store';
import axios from 'axios';
import ElementUI from 'element-ui';
import BaiduMap from 'vue-baidu-map';
import 'element-ui/lib/theme-chalk/index.css';    // 默认主题
// import '../static/css/theme-green/index.css';       // 浅绿色主题
import "babel-polyfill";
// import VueDirectiveImagePreviewer from 'vue-directive-image-previewer'
// import 'vue-directive-image-previewer/dist/assets/style.css'


Vue.use(ElementUI, { size: 'small' });
Vue.prototype.$axios = axios;
Vue.use(Vuex);

// 地图
Vue.use(BaiduMap, {
    // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
    ak: 'nSxiPohfziUaCuONe4ViUP2N'
})


export const Time = function time(date){
    var mat={};
    if (date == 'Thu Jan 01 1970 08:00:00 GMT+0800 (中国标准时间)' || date == null) {
        return '';
    } else {
        mat.M = date.getMonth()+1;//月份记得加1
        mat.Y = date.getFullYear();
        mat.D = date.getDate();
        return mat.Y+"年"+mat.M+"月"+mat.D+"日";
    }
}

//时间格式转换2
export const DateFormat = function format(date){
    // console.log(date);
    var mat = {};
    if (date == 'Thu Jan 01 1970 08:00:00 GMT+0800 (中国标准时间)') {
        return '无起始抄表时间';
    } else {
        mat.M = date.getMonth()+1;//月份记得加1
        mat.H = date.getHours();
        mat.s = date.getSeconds();
        mat.m = date.getMinutes();
        mat.Y = date.getFullYear();
        mat.D = date.getDate();
        mat.d = date.getDay();//星期几
        mat.d = check(mat.d);
        mat.H = check(mat.H);
        mat.M = check(mat.M);
        mat.D = check(mat.D);
        mat.s = check(mat.s);
        mat.m = check(mat.m);
        return mat.Y+"-"+mat.M+"-"+mat.D+" "+mat.H+":"+mat.m+":"+mat.s;
        // return mat.Y+"-"+mat.M+"-"+mat.D;
    }
}

//检查是不是两位数字，不足补全
function check(str){
    str=str.toString();
    if(str.length<2){
        str='0'+ str;
    }
    return str;
}

new Vue({
    router,
    store,  // 使用store
    render: h => h(App)
}).$mount('#app');

if (module.hot) {
    module.hot.accept();
}
